<template>
	<div class="p_Login_Return_aaa">
		<div class="p_Login_Return">
			<a href="javascript:history.back(-1)">
				<img src="../../assets/login/返回.png" />
			</a>
			<span>忘记密码</span>
		</div>
		<span class="p_Login_input2">
       		<input type="text" placeholder="请输入新密码" v-model="arr"/>
       	</span>
		<span class="p_Login_input2">
       		<input type="text" placeholder="请在次输入新密码" v-model="brr"/>
       	</span>
		<a id="getchongzhi" @click="getchongzhi()">
			<button class="huakuai">确认提交</button>
		</a>
	</div>
</template>

<script>

	export default {
		name: "chongzhi",
		data() {
			return {
				arr: "",
				brr: "",
				href: '#/userzhuce'
			}
		},
		methods: {

			getchongzhi: function() {
				var str = localStorage.obj;
				var arr = JSON.parse(str);
				var _this = this;
				if(this.arr == this.brr) {
				var _this = this;
				this.axios.get('http://localhost:3000/router/update', {
					params: {
						phone: arr[0].phone,
						psw: _this.brr,
						condition: _this.sql.user.xiugai
					}
				}).then(function(res) {
					if(res.data.msg.err) {
						//修改缓存
						var obj = {
									phone:arr[0].phone,
									psw:_this.brr
								}
								//缓存数据
								var arry = [];
								arry.push(obj);
								localStorage.setItem('obj',JSON.stringify(arry));
								//去缓存
								var str1 = localStorage.obj;
								var arr1 = JSON.parse(str1);
						document.location.href = _this.href;
					} else {
						console.log('修改密码失败');
					}
				})
			}else {
				console.log('两次密码不一致');
			}
				
			}
		}
	}
</script>

<style scoped>
	.p_Login_Return img {
		width: 10%;
		margin: 2%;
	}
	
	.p_Login_Return span {
		display: inline-block;
		margin-left: 5rem;
		width: 50%;
		vertical-align: 1rem;
		font-size: 2rem;
	}
	
	.p_Login_input2 {
		width: 80%;
		padding-bottom: 3%;
		border-bottom: 1px solid #999;
		display: block;
		margin: 5% auto;
	}
	
	.p_Login_input2 input {
		margin-left: 20px;
		border: none;
		outline: none;
		width: 83%;
		height: 20px;
		color: #999;
		font-size: 1.2rem;
	}
	
	.huakuai {
		width: 80%;
		height: 50px;
		background-color: rgb(255, 129, 173);
		border-radius: 20px;
		border: none;
		outline: none;
		color: white;
		margin: 5% 10%;
	}
</style>